EditDepartment = function() {
	return {
		
		initCompany : function(companyId) {
			$("#companyBelong").combotree({
				url           : '/pc/company/tree.htm',
				editable      : false,
				required      : false,
				disabled      : true,
				panelHeight   : 200,
				onLoadSuccess : function() {
					$("#companyId").val(companyId);
					$('#companyBelong').combotree('setValue', companyId);
				}
			});
		},
		
		initDepartment : function(companyId) {
			$("#parentDeptId").combotree({
				url           : '/pc/department/deptTree.htm?companyId=' + companyId,
				editable      : false,
				required      : false,
				disabled      : true,
				panelHeight   : 200,
				onLoadSuccess : function() {
					$('#parentDeptId').combotree('setValue', $("#parentDepartmentId").val());
				}
			});
		},
		
		submitForm : function() {
			$('#departmentForm').form('submit', {
				url      : "/pc/department/updateDepartmentInfo.htm",
				onSubmit : function() {
					return $('#departmentForm').form('validate');
				},
				success : function(data) {
					if("SUCCESS" == data) {
						Ict.info("保存成功", function() {
							Ict.closeWin();
							$('#departmentGrid').treegrid('reload');
						});
					} else {
						Ict.error("保存失败!");
					}
				}
			});
		},
		
		init : function() {
			var companyId = $("#companyId").val();
			EditDepartment.initCompany(companyId);
			EditDepartment.initDepartment(companyId);
		}
	};
}();

$(function(){
	EditDepartment.init();
	$("#displayOrder").numberspinner({
		editable : false,
		width    : 280
	});
});